home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 3 / Amiga Tools 3.iso / rexx / batchconvert.rexx < prev    next >
OS/2 REXX Batch file  |  1995-04-11  |  3KB  |  107 lines

  1. /* Image Engineer Script                  */
  2. /* Batch convert and render script        */
  3. /* by Simon Edwards                       */
  4. /*                                        */
  5. /* Demonstrates how to use ARexx to batch */
  6. /* load, render, convert and save images. */
  7.  
  8.  
  9. Options results        /* We want results */
  10. signal on error        /* Setup a place for errors to go */
  11.  
  12. address 'IMAGEENGINEER'
  13. IE_To_Front
  14.  
  15. 'TYPE 24bit'        /* Set load type */
  16.  
  17.             /* Get some file names from the user */
  18. 'GET_FILES "Select files to convert" "Ok" "ram:"'
  19. MyFileList=RESULT
  20.  
  21.             /* Ask the user how they want to render */
  22.             /* the images */
  23. 'GET_RENDER COLOUR "Set render options" 0 593920 8 1 256 1 2'
  24. RenderOptions=RESULT
  25.  
  26.             /* Get the desitination directory from the user */
  27. 'GET_DIR "Select Destination Directory" "Ok" "ram:"'
  28. DestDir=result
  29.             /* Fix DestDir so that we can just concatenate the */
  30.             /* file name to it to build complete paths */
  31. endpart=right(DestDir,1)
  32. if endpart~=":" & endpart~="/" then DestDir=DestDir||"/"
  33.  
  34.             /* Get the destination file format */
  35. 'GET_FILE_TYPE "Select Destination File Format"'
  36. FileType=RESULT
  37.  
  38.             /* Let the user enter a file extension to use */
  39. parse var FileType fileext .
  40. 'GET_STRING "Enter file extension" "Ok|Cancel" ".'||fileext||'"'
  41. FileExt=RESULT
  42.             /* Ask the user if they would like this done */
  43.             /* in the Background */
  44. 'REQUEST "Shall I do this in the Foreground or Background?" "Fore|Back"'
  45. Fore=RESULT
  46.  
  47. if Fore~=1 then do    /* If we should work in the background then     */
  48. 'WB_TO_FRONT'        /* we need to bring the WB to the front and     */
  49. 'SET_PRI -1'        /* drop our task priority to something friendly */
  50. end
  51.  
  52.             /* Keep going till we run out of files */
  53. do while MyFileList~=""
  54.             /* Get the next file name */
  55. parse var MyFileList x ';' MyFileList
  56.  
  57.             /* Extract the file name from the complete path */
  58. parse var x ':' temp
  59. if temp="" then temp=x
  60. do forever
  61. parse var temp FileName '/' temp
  62. if temp ="" then break
  63. end
  64.  
  65. 'OPEN "'||x||'"'    /* Open the image */
  66. Project=RESULT
  67.  
  68.             /* Set up this images render options */
  69. 'SET_RENDER' Project RenderOptions
  70.  
  71. if Fore=1 then do    /* See if we should be quiet or not when rendering */
  72. 'RENDER' Project
  73. end
  74. else do
  75.             /* We're in the background so we should render */
  76.             /* quietly */
  77. 'RENDER' Project 'QUIET'
  78. end
  79.  
  80.             /* Save the rendered image */
  81. 'SAVE' Project '"'||destdir||filename||fileext||'" "'||filetype||'"'
  82. 'CLOSE' Project
  83. end
  84.  
  85. 'IE_TO_FRONT'
  86. 'SET_PRI 0'
  87. 'REQUEST "All done."'
  88. exit
  89.  
  90. /*******************************************************************/
  91. /* This is where control goes when an error code is returned by IE */
  92. /* It puts up a message saying what happened and on which line     */
  93. /*******************************************************************/
  94. error:
  95. if RC=5 then do            /* Did the user just cancel us? */
  96.     IE_TO_FRONT
  97.     LAST_ERROR
  98.     'REQUEST "'||RESULT||'"'
  99.     exit
  100. end
  101. else do
  102.     IE_TO_FRONT
  103.     LAST_ERROR
  104.     'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!'
  105.     exit
  106. end
  107.